package me.wangshier.leetcode.medium;

/**
 * 11. 观光景点组合得分问题
 *
 * @Author: tongqianwen
 * @Date: 2025/3/5
 */
public class ScenicSpotCombinationScore {

    public static int solution(int[] values) {
        int maxI = values[0];
        int maxScore = 0;
        for (int i = 1; i < values.length; i++) {
            int currentI = values[i] - i;
            int currentScore = maxI + currentI;
            if (currentScore > maxScore) {
                maxScore = currentScore;
            }
            maxI = Math.max(maxI, values[i] + i);
        }
        return maxScore;
    }

    public static int solution1(int[] values) {
        int max = 0;
        for (int i = 0; i < values.length; i++) {
            for (int j = i + 1; j < values.length; j++) {
                int score = values[i] + values[j] + i - j;
                if (score > max) {
                    max = score;
                }
            }
        }
        return max;
    }

    public static void main(String[] args) {
        System.out.println(solution(new int[]{8, 3, 5, 5, 6}) == 11 ? 1 : 0);
        System.out.println(solution(new int[]{10, 4, 8, 7}) == 16 ? 1 : 0);
        System.out.println(solution(new int[]{1, 2, 3, 4, 5}) == 8 ? 1 : 0);
    }
}
